﻿@model CustomerAddressListModel
@using Nop.Web.Models.Customer;
@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";

    //title
    Html.AddTitleParts(T("PageTitle.Account").Text);
}
@section left
{
    @Html.Partial("MyAccountNavigation", Model.NavigationModel, new ViewDataDictionary())
}
<div class="page account-page address-list-page">
    <div class="page-title">
        <h1>@T("Account.MyAccount") - @T("Account.CustomerAddresses")</h1>
    </div>
    <div class="page-body">
        <div class="address-list">
            @if (Model.Addresses.Count > 0)
            {
                for (int i = 0; i < Model.Addresses.Count; i++)
                {
                    var address = Model.Addresses[i];
                    
                <div class="section address-item">
                    <div class="title">
                        <strong>@address.FirstName @address.LastName</strong>
                    </div>
                    <ul class="info">
                        <li class="name">
                            @address.FirstName @address.LastName
                        </li>
                        <li class="email">
                            @Html.LabelFor(model => model.Addresses[i].Email, new { }, ":")
                            @address.Email
                        </li>
                        @if (address.PhoneEnabled)
                        {
                            <li class="phone">
                                @Html.LabelFor(model => model.Addresses[i].PhoneNumber, new { }, ":")
                                @address.PhoneNumber
                            </li>
                        }
                        @if (address.FaxEnabled)
                        {
                            <li class="fax">
                                @Html.LabelFor(model => model.Addresses[i].FaxNumber, new { }, ":")
                                @address.FaxNumber
                            </li>
                        }
                        @if (address.CompanyEnabled && !String.IsNullOrEmpty(address.Company))
                        {
                            <li class="company">@address.Company</li>
                        }
                        @if (address.StreetAddressEnabled)
                        {
                            <li class="address1">
                                @address.Address1
                            </li>
                        }
                        @if (address.StreetAddress2Enabled && !String.IsNullOrEmpty(address.Address2))
                        {
                            <li class="address2">
                                @address.Address2
                            </li>
                        }
                        @if (address.CityEnabled || address.StateProvinceEnabled || address.ZipPostalCodeEnabled)
                        {
                            var cityStateZip = "";
                            if (address.CityEnabled)
                            {
                                cityStateZip = address.City;
                                if (address.StateProvinceEnabled || address.ZipPostalCodeEnabled)
                                {
                                    cityStateZip += ",";
                                }
                            }
                            if (address.StateProvinceEnabled)
                            {
                                if (!String.IsNullOrEmpty(cityStateZip))
                                {
                                    cityStateZip += " ";
                                }
                                cityStateZip += address.StateProvinceName;
                            }
                            if (address.ZipPostalCodeEnabled)
                            {
                                if (!String.IsNullOrEmpty(cityStateZip))
                                {
                                    cityStateZip += " ";
                                }
                                cityStateZip += address.ZipPostalCode;
                            }
                            
                            <li class="city-state-zip">
                                @cityStateZip
                            </li>
                        }
                        @if (address.CountryEnabled && !String.IsNullOrEmpty(address.CountryName))
                        {
                            <li class="country">
                                @address.CountryName
                            </li>
                        }
                    </ul>
                    <div class="buttons">
                        <input type="button" class="button-2 edit-address-button" onclick="location.href='@(Url.RouteUrl("CustomerAddressEdit", new { addressId = address.Id }))'" value='@T("Common.Edit")' />
                        <input type="button" class="button-2 delete-address-button" onclick="if (confirm('@(T("Common.AreYouSure").Text)')) {location.href='@(Url.RouteUrl("CustomerAddressDelete", new { addressId = address.Id }))';}" value="@T("Common.Delete")" />
                    </div>
                </div>
                }
            }
            else
            {
                @T("Account.CustomerAddresses.NoAddresses")
            }
        </div>
        <div class="add-button">
            <input type="button" class="button-1 add-address-button" onclick="location.href='@Url.RouteUrl("CustomerAddressAdd")'" value="@T("Common.AddNew")" />
        </div>
    </div>
</div>
